<template>
  <div class="body-content">
    <el-form ref="form" :model="knowledgeFile" label-width="100px">
      <el-form-item label="知识库名称">
        <el-input v-model="knowledgeDb.knowledgeTitle"></el-input>
      </el-form-item>
      <el-form-item label="知识库类型">
        <el-select v-model="knowledgeDb.rType" placeholder="请选择类型">
          <el-option label="类型一" value="技术"></el-option>
          <el-option label="类型二" value="杂闻"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="knowledgeDb.date1" style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-time-picker placeholder="选择时间" v-model="knowledgeDb.updateTime" style="width: 100%;"></el-time-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="隐私模式">
        <el-switch v-model="knowledgeDb.selfmode"></el-switch>
      </el-form-item>
      <el-form-item label="概述">
        <el-input type="textarea" v-model="knowledgeDb.desc"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { newKnowledgeDb } from '@/api/table'
export default {
  data() {
    return {
      activeName: '',
      knowledgeDb: {
          ownerAccount: '',
          ownerNickname: '',
          rType: '',
          updateTime: '',
          selfmode: false,
          type: [],
          knowledgeTitle: '',
          desc: ''
        },
      
    }
  },
  computed: {
    ...mapGetters([
      'nickName',
      'token'
    ])
  },
  mounted() {
    console.log(this.token,this.nickName)
  },
  methods:{
    onSubmit() {
        console.log('submit!');
        this.knowledgeDb.ownerAccount = this.token
        this.knowledgeDb.ownerNickname = this.nickName
        console.log(this.knowledgeDb)
        newKnowledgeDb(this.knowledgeDb).thne(response => {
          console.log(response)
          if(response.data > 0){
            this.$message("完成!")
          }
        })
    }
  }
};
</script>

<style lang="scss" scoped>
.body {
  margin: 0 !important;
}
</style>